#ifndef N2REGION_H_2009_10_12
#define N2REGION_H_2009_10_12

#include "N2Geometry.h"
#include "N1Lib.h"

class N2Region : public N1Object {
protected:
    N2Rect    m_rect;
    N2Rect   *m_rects;
    uint32    m_count;

public:
    N1NAME_DECL

    N2Region(const N2Rect &rect);
    N2Region(const N2Region &r);

    virtual ~N2Region();

    N2Rect getBounds() const ;

    bool isContains(const N2Point &point) const ;
    bool isContains(const N2Rect &rect) const ;
    bool isContains(const N2Region &rgn) const ;
};

class N2RegionArea : public N1Object {
public:
    N2RegionArea(const N2Region &rgn, const N2Rect &rect);
    virtual ~N2RegionArea();

    N1NAME_DECL

    bool inArea(N2Coord x, N2Coord y) 
    {
        BYTE *pRow = (BYTE*)m_pData + m_nByteInRow * y;
        return (*(pRow + x/8) >> x%8) & 1;
    }
    void setPoint(N2Coord x, N2Coord y);

protected:

    char *m_pData;
    uint32 m_nByteInRow;
    uint32 m_nSize;
    uint32 m_nWidth, m_nHeight;
};


#endif //N2REGION_H_2009_10_12
